package com.gitee.wsl.mathematics.matrix.mat

/**
 * 对角阵
 */
class DiagonalMatrix(diagonal: List<Double>) : AbstractSquareMatrix<DiagonalMatrix>(diagonal.size,
       proxy = FunDataProxy(
           diagonal.size*diagonal.size,
                diagonal.size,
                valueFun = {i,j->
                    if(i==j) diagonal[i] else 0.0
                 }
       )
){

    override val self: DiagonalMatrix
        get() = this

    //val rank get() = diagonal.filter { it != .0 }.size
    //val trace get() = diagonal.sum()

    /*
    override val det by lazy {
        if (rank == diagonal.size)
            diagonal.fold(1.0) { r, i -> r * i }
        else .0
    }
    */



}